package zcjq.d905;

import java.util.Arrays;
import java.util.Scanner;

public class Plant {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.nextLine());
        int[] nums = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(s -> s.equals("B") ? 1 : 0).toArray();

        int total = 0, left = 0, right = 0;
        while (right < N) {
            if (nums[right] == 1) { //右端遇到树
                int empty = right - left;
                if (left == 0 || right == N) {
                    empty -= 1;
                } else {
                    empty -= 2;
                }
                if (empty > 0) {
                    total += (empty + 1) / 2;
                }
                left = right + 1;
            }
            right++;
        }
        if (right > left) {
            int empty = right - left;
            if (left != 0 || right != N) {
                empty -= 1;
            }
            if (empty > 0) {
                total += (empty + 1) / 2;
            }
        }
        System.out.println(total);
    }
}
